/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package event;

import dbaccess.Database;
import java.sql.ResultSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author albrecht
 */
public class Login {
    public String displaystyle;
    public String pwerror;
    
    public Login() {
        this.displaystyle="block";
        this.pwerror="Benutzername oder Passwort falsch eingegeben";
    }

    public String getDisplaystyle() {
        return displaystyle;
    }

    public void setDisplaystyle(String displaystyle) {
        this.displaystyle = displaystyle;
    }

    public String getPwerror() {
        return pwerror;
    }

    public void setPwerror(String pwerror) {
        this.pwerror = pwerror;
    }
    public void actionPwerror(HttpServletRequest request, HttpServletResponse response){
        String pw=request.getParameter("passwort");
        String benutzer = request.getParameter("benutzer");
        
        Database db=new Database();
        db.Connect();
        ResultSet rs = db.ReturnQuery("SELECT Password FROM User WHERE Username = \""+benutzer+"\";");
        try{
            while(rs.next()){
                  if(rs.getObject("Password").equals(pw)){
                      this.setDisplaystyle("none");
                      request.setAttribute("display",this.getDisplaystyle());     
                  }                 
            }
        }
        catch(Exception e)
        {
            request.setAttribute("pwerror",this.getPwerror()); 
        }
    }
}
